window.onload = function(){
	var 
		oList   = $('list'),
		oCore   = $('core'),
		oNotice = $('notice'),
		oTime   = $('time'),
		oGover  = $('gameover'),
		oScore  = $('score'),
		oWran   = $('warn'),
		oSort   = $('sort'),
		aSpan   = Array.from(oCore.children),
		aLi     = Array.from(oList.children),
		aA      = Array.from(oGover.children);
	//关闭页面选蓝
	document.onselectstart = function () {
        return false;
    }
	//给每一个li添加点击事件
	aLi.forEach(function(v){
		v.onclick = function(){
			oNotice.style.display = "block";
			oList.style.display   = 'none';
			//定义选择的难度
			let iLevel = Number(this.getAttribute('data-level'));
			switch(iLevel){
				case 1 :
					me.ifrequency = 200;
					break;
				case 2 :
					me.ifrequency = 400;
					break;
				case 3 :
					me.ifrequency = 600;
					break;
				case 4 :
					me.ifrequency = 800;
					break;
			}
		}	
	});

	//添加时间
	gettime(1492166830076);
	setInterval(function(){
		gettime(1492166830076);
	},1000);
	//添加平分特效
	aSpan.forEach(function (v, k) {
		v.index = k;
		v.onmouseenter = function () {
			aSpan.forEach(function (n, m) {
				if(m <= v.index) {
					n.className = 'yellow';
				} else {
					n.className = '';
				}
				return aSpan.iKey = k;
			});
		};
	});
	
	//评分完毕,开始游戏
	oCore.onclick = function(){
		if (aSpan.iKey < 3) {
			oWran.style.display = 'block';
			bufferMove(oWran,{top:100})
			setTimeout(function(){
				oWran.style.display = 'none';
			},4000)
		}else{
			oNotice.style.display = 'none';
			//加载游戏
			play.loading();
			//开始游戏
			play.work();
			//消灭敌机
			play.kill();
			//游戏结束
			play.gameover();
		}
	};
	//继续游戏
	aA[0].onclick = function(){
		//显示框消失
		oGover.style.display = 'none';
		me.el.style.display = 'block';
		play.aScore.push(play.score);
		play.score = 0; //重置分数
		//加载游戏
		play.loading();
		//重新游戏
		play.rework();
		//消灭敌机
		play.kill();
		//游戏结束
		play.gameover();
	};
	//记录分数
	setInterval(function(){
		oScore.innerHTML = play.score + '分';
	},100);
	//不玩了
	aA[1].onclick = function(){
		//显示框消失
		oGover.style.display = 'none';
		play.exit();
	};
	
}